package org.csu.molediary.api.controller.back;


import org.csu.molediary.api.common.CommonResponse;
import org.csu.molediary.api.service.AdminDiaryService;
import org.csu.molediary.api.vo.AdminDiaryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Controller
@RequestMapping("/admin/")
public class AdminDiaryController {

    @Autowired
    private AdminDiaryService adminDiaryService;

    @GetMapping("diaries/allDiary")
    @ResponseBody
    //管理员获得所有日记
    public CommonResponse<List<AdminDiaryVO>> adminGetAllDiary(){
        return adminDiaryService.adminGetAllDiary();
    }

    @GetMapping("diaries/diaryList/{accountid}")
    @ResponseBody
    //管理员通过用户id查找日记
    public CommonResponse<List<AdminDiaryVO>> adminGetDiaryByAccountId(@PathVariable String accountid){
        return adminDiaryService.adminGetDiaryByAccountId(accountid);
    }

    @PostMapping("diaries/deleteDiary")
    @ResponseBody
    //管理员删除日记
    public CommonResponse<String> adminDeleteDiary(@RequestParam int contentid){
        return adminDiaryService.adminDeleteDiary(contentid);
    }

}
